// hyb_yl/userLife/pages/hospitalList/hospitalList.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    tabIndex:0,
    feileiIndex:false,
    fenleiList:['专科','脑科','全科','口腔科科','肠胃科'],
    fenleiText:'全部分类',
    choseItemIndex:0,
    page:0,
    pagesize:10,
    groupid:"",
    order:"",
    list:[],
    type_arr:[
      {
        id:'',
        name:'全部'
      },{
      id:1,
      name:'医院'
    },{
      id:2,
      name:'药房'
    },{
      id:3,
      name:'体检机构'
    },{
      id:4,
      name:'诊所'
    },]
  },
  goback:function(e){
    wx.navigateTo({
      url: '/hyb_yl/mycenter/pages/mechanism/mechanism?hid=' + e.currentTarget.dataset.hid,
    })
  },
  stor_btn:function(e){
    console.log(e.currentTarget.dataset.index)
    this.setData({
      tabIndex:e.currentTarget.dataset.index,
      order:e.currentTarget.dataset.index,
      page:0,
      list:[]
    })
    this.getList();
  },
  chose_fenlei:function(e){
    this.setData({
      feileiIndex:!this.data.feileiIndex
    })
  },
  chose_item:function(e){
    var index=e.currentTarget.dataset.index;
    var id = e.currentTarget.dataset.id;
    var name=e.currentTarget.dataset.name;
    if(id==''){
      this.setData({
        fenleiText:"全部分类",
        feileiIndex:!this.data.feileiIndex,
        choseItemIndex:0,
        groupid:'',
        page:0,
        list:[]
      })
    }else{
      this.setData({
        fenleiText:name,
        feileiIndex:!this.data.feileiIndex,
        choseItemIndex:index,
        groupid:id,
        page:0,
        list:[]
      })
    }
    this.getList();
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    
    that.getList();
  },
  getList:function(){
    var that = this;
    app.util.request({
      'url':"entry/wxapp/index.allhospital",
      data:{
        page:that.data.page,
        pagesize:that.data.pagesize,
        groupid:that.data.groupid,
        order:that.data.order
      },
      success:function(res){
        var page = that.data.page
        page = page + 1;
        that.setData({
          page:page,
          list:that.data.list.concat(res.data)
        })
      }
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    this.getList();
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})